home *** CD-ROM | disk | FTP | other *** search
/ Celestin Apprentice 2 / Apprentice-Release2.iso / Tools / Languages / Python 1.1 / Doc / myformat.perl < prev    next >
Encoding:
Text File  |  1994-08-12  |  3.7 KB  |  154 lines  |  [TEXT/R*ch]

  1. # myformat.perl by Guido van Rossum <guido@cwi.nl> 25 Jan 1994
  2. #
  3. # Extension to LaTeX2HTML for documents using myformat.sty.
  4. # Subroutines of the form do_cmd_<name> here define translations
  5. # for LaTeX commands \<name> defined in the corresponding .sty file.
  6. #
  7. # XXX Not complete: \indexii etc.; \funcitem etc.
  8.  
  9. package main; 
  10.  
  11. # \bcode and \ecode brackets around verbatim
  12.  
  13. sub do_cmd_bcode{ @_[0]; }
  14. sub do_cmd_ecode{ @_[0]; }
  15.  
  16. # words typeset in a special way (not in HTML though)
  17.  
  18. sub do_cmd_ABC{ join('', 'ABC', @_[0]); }
  19. sub do_cmd_UNIX{ join('', 'Unix', @_[0]); }
  20. sub do_cmd_ASCII{ join('', 'ASCII', @_[0]); }
  21. sub do_cmd_C{ join('', 'C', @_[0]); }
  22. sub do_cmd_Cpp{ join('', 'C++', @_[0]); }
  23. sub do_cmd_EOF{ join('', 'EOF', @_[0]); }
  24.  
  25. # texinfo-like formatting commands: \code{...} etc.
  26.  
  27. sub do_cmd_code{
  28.     local($_) = @_;
  29.     s/(<#[0-9]+#>)(.*)(\1)/<CODE>\2<\/CODE>/;
  30.     $_;
  31. }
  32.  
  33. sub do_cmd_kbd{
  34.     local($_) = @_;
  35.     s/(<#[0-9]+#>)(.*)(\1)/<KBD>\2<\/KBD>/;
  36.     $_;
  37. }
  38.  
  39. sub do_cmd_key{
  40.     local($_) = @_;
  41.     s/(<#[0-9]+#>)(.*)(\1)/<TT>\2<\/TT>/;
  42.     $_;
  43. }
  44.  
  45. sub do_cmd_samp{
  46.     local($_) = @_;
  47.     s/(<#[0-9]+#>)(.*)(\1)/`<SAMP>\2<\/SAMP>'/;
  48.     $_;
  49. }
  50.  
  51. sub do_cmd_var{
  52.     local($_) = @_;
  53.     s/(<#[0-9]+#>)(.*)(\1)/<VAR>\2<\/VAR>/;
  54.     $_;
  55. }
  56.  
  57. sub do_cmd_file{
  58.     local($_) = @_;
  59.     s/(<#[0-9]+#>)(.*)(\1)/`<CODE>\2<\/CODE>'/;
  60.     $_;
  61. }
  62.  
  63. sub do_cmd_dfn{
  64.     local($_) = @_;
  65.     s/(<#[0-9]+#>)(.*)(\1)/<I><DFN>\2<\/DFN><\/I>/;
  66.     $_;
  67. }
  68.  
  69. sub do_cmd_emph{
  70.     local($_) = @_;
  71.     s/(<#[0-9]+#>)(.*)(\1)/<EM>\2<\/EM>/;
  72.     $_;
  73. }
  74.  
  75. sub do_cmd_strong{
  76.     local($_) = @_;
  77.     s/(<#[0-9]+#>)(.*)(\1)/<STRONG>\2<\/STRONG>/;
  78.     $_;
  79. }
  80.  
  81. # index commands
  82.  
  83. sub do_cmd_indexii{
  84.     local($_) = @_;
  85.     s/$next_pair_pr_rx//o;
  86.     local($br_id1, $str1) = ($1, $2);
  87.     s/$next_pair_pr_rx//o;
  88.     local($br_id2, $str2) = ($1, $2);
  89.     join('', &make_index_entry($br_id1, "$str1 $str2"),
  90.          &make_index_entry($br_id2, "$str2, $str1"), $_);
  91. }
  92.  
  93. sub do_cmd_indexiii{
  94.     local($_) = @_;
  95.     s/$next_pair_pr_rx//o;
  96.     local($br_id1, $str1) = ($1, $2);
  97.     s/$next_pair_pr_rx//o;
  98.     local($br_id2, $str2) = ($1, $2);
  99.     s/$next_pair_pr_rx//o;
  100.     local($br_id3, $str3) = ($1, $2);
  101.     join('', &make_index_entry($br_id1, "$str1 $str2 $str3"),
  102.          &make_index_entry($br_id2, "$str2 $str3, $str1"),
  103.          &make_index_entry($br_id3, "$str3, $str1 $str2"),
  104.           $_);
  105. }
  106.  
  107. sub do_cmd_indexiv{
  108.     local($_) = @_;
  109.     s/$next_pair_pr_rx//o;
  110.     local($br_id1, $str1) = ($1, $2);
  111.     s/$next_pair_pr_rx//o;
  112.     local($br_id2, $str2) = ($1, $2);
  113.     s/$next_pair_pr_rx//o;
  114.     local($br_id3, $str3) = ($1, $2);
  115.     s/$next_pair_pr_rx//o;
  116.     local($br_id4, $str4) = ($1, $2);
  117.     join('', &make_index_entry($br_id1, "$str1 $str2 $str3 $str4"),
  118.          &make_index_entry($br_id2, "$str2 $str3 $str4, $str1"),
  119.          &make_index_entry($br_id3, "$str3 $str4, $str1 $str2"),
  120.          &make_index_entry($br_id4, "$str4, $str1 $str2 $str3"),
  121.           $_);
  122. }
  123.  
  124. sub do_cmd_ttindex{
  125.     &do_cmd_index(@_);
  126. }
  127.  
  128. sub my_typed_index_helper{
  129.     local($word, $_) = @_;
  130.     s/$next_pair_pr_rx//o;
  131.     local($br_id, $str) = ($1, $2);
  132.     join('', &make_index_entry($br_id, "$str $word"),
  133.          &make_index_entry($br_id, "$word, $str"), $_);
  134. }
  135.  
  136. sub do_cmd_stindex{ &my_typed_index_helper('statement', @_); }
  137. sub do_cmd_kwindex{ &my_typed_index_helper('keyword', @_); }
  138. sub do_cmd_opindex{ &my_typed_index_helper('operator', @_); }
  139. sub do_cmd_exindex{ &my_typed_index_helper('exception', @_); }
  140. sub do_cmd_obindex{ &my_typed_index_helper('object', @_); }
  141.  
  142. sub my_parword_index_helper{
  143.     local($word, $_) = @_;
  144.     s/$next_pair_pr_rx//o;
  145.     local($br_id, $str) = ($1, $2);
  146.     join('', &make_index_entry($br_id, "$str ($word)"), $_);
  147. }
  148.  
  149. sub do_cmd_bifuncindex{ &my_parword_index_helper('built-in function', @_); }
  150. sub do_cmd_bimodindex{ &my_parword_index_helper('built-in module', @_); }
  151. sub do_cmd_bifuncindex{ &my_parword_index_helper('standard module', @_); }
  152.  
  153. 1;                # This must be the last line
  154.